<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/fan-zhuan-dan-ci-shun-xu-lcof/
     */
    let s = '  hello  world!  '
    function reverseWords(s) {
      return s.trim().split(' ').filter(item => item !== '').reverse().join(' ')
    }
    console.log(reverseWords(s));
  </script>
</body>
</html>